package com.chen;




public class DemoDaemon {
    public static void main(String[] args) throws InterruptedException {
      Thread t1=   new Thread(new Runnable() {
             @Override
             public void run() {
                 System.out.println("t1线程执行开始");
                 Thread daemon=new Thread(new Runnable() {
                     @Override
                     public void run() {
                         while (true){
                             System.out.println("daemon执行");
                         }
                     }
                 });
                 daemon.setDaemon(true); //所有的线程执行完毕,守护线程才结束
                 daemon.start();
                 System.out.println("t1线程执行完毕");
             }
         });
        t1.start();
        Thread.sleep(1000);
        System.out.println("main线程执行完毕");
    }


}
